<?php

namespace App\Http\Controllers\Admin;

use App\Models\Menu;
use App\Models\Role;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class RoleController extends Controller
{
    private $menu;
    private $role;
    public function __construct(){
        $this->menu = new Menu();
        $this->role = new Role();
    }
    public function index(){
        return view('admin.role.index');
    }
    public function add(){
        $params=[
            'nocount'=>true,
            'where'=>[
                ['disabled',1]
            ],
            'order'=>'created_at','desc',
            'getfield'=>true,
            'field'=>['id','title','status','parent_id as pid','psort','menu_route','routes','description','created_at','updated_at','id as sid']
        ];
        $rs = $this->menu->getList($params);
        $arr=array();
        foreach ($rs['row'] as $k=>$v){
            $arr[]=(array)$v;
        }
        $result = treeNode($arr,0);
        return view('admin.role.add',['menuList'=>$result]);
    }
}
